package com.sanno.account.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sanno.account.dao.AccountDao;
import com.sanno.account.entity.Account;
import com.sanno.account.service.AccountService;
import com.sanno.common.entity.SccDrugstore;
import com.sanno.common.entity.SncUserLogin;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AccountServiceImpl extends ServiceImpl<AccountDao,SncUserLogin> implements AccountService{

    @Resource
    private AccountDao accountDao;

    @Override
    public List<Account> getAccount(String name,String province,String city,String county) {
        List<Account> list = accountDao.getAccount(name,province,city,county);
        for (Account account : list) {
            account.setAddressDetail(
                    account.getProvince()+account.getCity()+account.getCounty()+","+account.getStoreName());
        }
        return list;
    }

    @Override
    public List<SncUserLogin> findUserLogin(String name, String province, String city, String county) {
        List<SncUserLogin> list = accountDao.findUserLogin(name,province,city,county);
        for (SncUserLogin sncUserLogin : list) {
            String addressDetail = "";
            List<SccDrugstore> sccDrugstoreList = sncUserLogin.getSccDrugstoreList();
            for (SccDrugstore sccDrugstore : sccDrugstoreList) {
                addressDetail += sccDrugstore.getProvince()+sccDrugstore.getCity()+sccDrugstore.getCounty()+","+sccDrugstore.getStoreName()+".";
            }
            sncUserLogin.setAddressDetail(addressDetail);
        }
        return list;
    }
}
